<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Jedrzej\Pimpable\PimpableTrait;

class MerchantRegister extends Model
{
    use HasFactory;
    use PimpableTrait;
//    use SoftDeletes;

    /**
     * 可执行搜索的字段
     */
    public $searchable = [
        'id',
        'user_id',
        'class',
        'name',
        'username',
        'keyword',
        'merchant_type',
        'status',
    ];

    /**
     * 店铺审核状态的类型
     */
    public $statusEnum=[
        'underreview' => '审核中',
        'approved' => '审核通过',
        'auditfailed' => '审核未通过'
    ];

    /**
     *可批量复制字段
     */
    public $fillable = [
        'user_id',
        'class',
        'name',
        'username',
        'password',
        'move_show',
        'banner',
        'brief',
        'avatar',
        'principal_name',
        'principal_phone',
        'keyword',
        'service_phone',
        'province',
        'city',
        'district',
        'detailed_address',
        'fees',
        'merchant_type',
        'check_time',
        'fail_message',
    ];

    /**
     * 默认使用倒叙的字段
     */
    public $defaultSortCriteria = [
        'id,desc',
    ];


    /**
     * 用户对应的用户地址表
     */
    protected function user(){
        return $this->belongsTo(UserAddress::class,'user_id','id');
    }

}
